<?php

class Bib_Controller_Action extends Zend_Controller_Action {
	
	/**
	 * Current user object
	 * @var User
	 */
	protected $user;
	
	/**
	 * Default session namespace
	 * @var Zend_Session_Namespace
	 */
	protected $_session;
	
	function init() {
		//me!
		$this->user = Zend_Auth::getInstance()->getIdentity();
		
		$this->_session = new Zend_Session_Namespace('controller_' . get_class($this));
		
		$view = new MM_View();
		
		foreach ($this->view->getScriptPaths() as $path)
			$view->addScriptPath($path);
		
			
		foreach ($this->view->getHelperPaths() as $path)
			$view->addHelperPath($path);
			
		$this->view = $view;
		$this->view->baseURL = Zend_Registry::get('global')->url;
		$this->view->user = $this->user;	
		// custom viewrenderer
		
		Zend_Controller_Action_HelperBroker::removeHelper('viewRenderer');
		
		$vr = new MM_ViewRenderer($view);
		$vr->setActionController($this);
			
		Zend_Controller_Action_HelperBroker::addHelper($vr);
		
		// custom helpers
		Zend_Controller_Action_HelperBroker::addPrefix('MM_Controller_Action_Helper');
		
	}

    public function _($messageId, $locale = null)
    {
        return $this->translate->translate($messageId, $locale);
    }
    
}
